<%-- 
    Document   : RemoveCartItem
    Created on : Jul 21, 2011, 2:41:16 AM
    Author     : HOANG ANH
--%>

<jsp:useBean id="BeanCart" scope="session" class="BUS.BUSCart" />
<%
    Integer i = Integer.parseInt(request.getParameter("ID"));
    String coman = request.getParameter("Button");
    if (i > 0) {
        if (coman.equals("Remove")) {

            BeanCart.removeProduct(i);

        } else if (coman.equals("Change Quantity")) {
            try {
                int Quantity = Integer.parseInt(request.getParameter("quantity"));
                if (Quantity > 0) {
                    BeanCart.editQuantity(i, Quantity);
                } else if (Quantity == 0) {
                    BeanCart.removeProduct(i);
                } else {
                    response.sendRedirect("InputError.jsp");
                    return;
                }
            } catch (Exception ex) {
                response.sendRedirect("InputError.jsp");
                return;
            }
        }
    }
    response.sendRedirect("ViewCart.jsp");
%>
